package com.chencs.common.lmadmin.controller;


import com.alibaba.fastjson.JSON;
import com.chencs.app.AppCommon;
import com.chencs.common.lmadmin.service.LmBannerService;
import com.chencs.vo.biz.lianmeng.LmBanner;
import com.chencs.vo.biz.lianmeng.LmMember;
import com.chencs.vo.net.response.ResponseBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/m/lmBanner")
public class LmBannerController {


    @Autowired
    private LmBannerService lmBannerService;

    @RequestMapping(value = "/getList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String memberList() {
        List<LmBanner> banners = lmBannerService.banner_list();
        return JSON.toJSON(banners).toString();
    }

    @RequestMapping(value = "/findLmBannerById", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String findLmBannerById(@RequestBody  String id) {
        LmBanner banner = lmBannerService.findLmBannerById(id);
        return JSON.toJSON(banner).toString();
    }

    @RequestMapping(value = "/insertBanner", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String insertBanner(@RequestBody  LmBanner banner) {

        ResponseBase base = new ResponseBase();
         lmBannerService.insertBannser(banner);
        base.setCode(AppCommon.SUCCESS);
        base.setMsg("添加成功");
        return JSON.toJSON(base).toString();
    }

    @RequestMapping(value = "/updateBanner", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String updateBanner(@RequestBody  LmBanner banner) {
        ResponseBase base = new ResponseBase();
        lmBannerService.upateBannser(banner);
        base.setCode(AppCommon.SUCCESS);
        base.setMsg("修改成功");
        return JSON.toJSON(base).toString();
    }

    @RequestMapping(value = "/delBanner", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String delBanner(@RequestBody  String id) {
        ResponseBase base = new ResponseBase();
        lmBannerService.delBannser(id);
        base.setMsg("删除成功");
        base.setCode(AppCommon.SUCCESS);
        return JSON.toJSON(base).toString();
    }

}
